package com.example.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.demo.entity.TblAsset;
import com.example.demo.entity.TblRegion;
import com.example.demo.mapper.asset.TblAssetMapper;
import com.example.demo.mapper.equity.TblRegionMapper;
import com.example.demo.service.TblAssetService;
import com.example.demo.service.TblRegionService;
import com.example.demo.vo.AssetInfoResponse;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("/index")
public class IndexController {
	@Autowired
	private TblAssetMapper tblAssetMapper;
	@Autowired
	private TblRegionMapper tblRegionMapper;
	@Autowired
	private TblRegionService tblRegionService;
	@Autowired
	private TblAssetService tblAssetService;

	@GetMapping("/asset")
	public ResponseEntity<TblAsset> asset() {
		log.info("asset");
		TblAsset asset = tblAssetMapper.info(1874022285771763713L);
		return ResponseEntity.ok(asset);
	}

	@GetMapping("/asset/join")
	public ResponseEntity<AssetInfoResponse> assetJoin() {
		log.info("assetJoin");
		AssetInfoResponse asset = tblAssetService.queryAssetInfoResponseInfoWithGoodsId("1874022285771763713");
		return ResponseEntity.ok(asset);
	}

	@GetMapping("/region")
	public ResponseEntity<List<TblRegion>> region() {
		log.info("region");
		List<TblRegion> list = tblRegionMapper.selectWithId(270L);
		return ResponseEntity.ok(list);
	}

	@GetMapping("/region/like")
	public ResponseEntity<List<TblRegion>> like() {
		log.info("queryLike");
		List<TblRegion> list = tblRegionService.queryLike();
		return ResponseEntity.ok(list);
	}
}
